package com.pie.face_pie.service;

import com.pie.face_pie.mapper.RegisterMapper;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import javax.sql.rowset.serial.SerialBlob;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.Arrays;

@Component
public class SendService {

    @Autowired
    RegisterMapper registerMapper;

    @Autowired
    RabbitTemplate rabbitTemplate;
    @Async
    public void send(InputStream[] inputStreams, String id) throws IOException, SQLException {
        registerMapper.registerWithMaxCapacity(id, Arrays.stream(inputStreams).toList());
        String exchangeNamed = "faceExchange";
        rabbitTemplate.convertAndSend(exchangeNamed,"register",id);
        System.out.println("b");
    }
}
